﻿<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="UserManagement.aspx.cs"
    Inherits="YiCreateWebApp.User.UserManagement" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title>用户管理</title>
</head>
<body>
    <form id="form1" runat="server">
    <div>
        <div>
            <h2 align="center">
                用户管理</h2>
        </div>
        <div align="center">
            <asp:DataList ID="DataList1" runat="server" CellPadding="4" ForeColor="#333333" Font-Size="9pt"
                OnEditCommand="DataList1_EditCommand" OnCancelCommand="DataList1_CancelCommand"
                OnUpdateCommand="DataList1_UpdateCommand" OnDeleteCommand="DataList1_DeleteCommand"
                OnItemCommand="DataList1_ItemCommand">
                <%--             OnItemDataBound="DataList1_ItemDataBound">--%>
                <FooterStyle BackColor="#5D7B9D" Font-Bold="true" ForeColor="White" />
                <SelectedItemStyle BackColor="#E2DED6" Font-Bold="true" ForeColor="#333333" />
                <%--****************Item Template 模板设计代码***********--%>
                <%--****************ItemTemplate为DataList中的项提供内容和布局所要求的模板***********--%>
                <ItemTemplate>
                    <table style="width: 470px; font-size: 9pt;">
                        <tr>
                            <td style="width: 47px">
                                <asp:LinkButton ID="lnkbtnUserName" runat="server" CommandName="select" Text='<%#DataBinder.Eval(Container.DataItem,"UserName") %>'></asp:LinkButton>
                            </td>
                            <td style="width: 74px">
                                <asp:Label ID="Label2" runat="server" Text='<%#DataBinder.Eval(Container.DataItem,"Email") %>'></asp:Label>
                            </td>
                            <td style="width: 81px">
                                <asp:CheckBox ID="chkRole" runat="server" Enabled="false" Checked='<%#DataBinder.Eval(Container.DataItem,"Role") %>' />
                            </td>
                            <td style="width: 90px">
                                <asp:Button ID="btnEdit" runat="server" CommandName="edit" Text="编辑" />
                                <asp:Button ID="btnDelete" runat="server" CommandName="delete" Text="删除" CommandArgument='<%#DataBinder.Eval(Container.DataItem,"UserId") %>'
                                    OnLoad="btn_DeleteLoads" />
                            </td>
                            <td style="width: 86px">
                                <asp:Button ID="btnSetRole" CommandName="setRole" runat="server" CommandArgument='<%#DataBinder.Eval(Container.DataItem,"UserId") %>'
                                    Text='<%#(bool)DataBinder.Eval(Container.DataItem,"Role")==true? "取消管理员权限":"设为管理员权限"%>'/>
                            </td>
                        </tr>
                    </table>
                </ItemTemplate>
                <%--****************EditItem Template 模板设计代码***********--%>
                <EditItemTemplate>
                    <table style="width: 297px; height: 59px; font-size: 9pt;">
                        <tr>
                            <td style="width: 75px; height: 19px;">
                                用户名：
                            </td>
                            <td style="width: 131px; height: 19px;">
                                <asp:Label ID="lblUserName" runat="server" Text='<%#DataBinder.Eval(Container.DataItem,"UserName") %>'></asp:Label>
                            </td>
                            <td style="width: 95px; height: 19px;">
                            </td>
                        </tr>
                        <tr>
                            <td style="width: 75px;">
                                旧密码：
                            </td>
                            <td style="width: 131px;">
                                <asp:TextBox ID="txtOldpwd" runat="server" TextMode="Password" Width="98px"></asp:TextBox>
                                <asp:RequiredFieldValidator ID="RequiredFieldValidator1" ControlToValidate="txtOldpwd"
                                    runat="server" ForeColor="Red" ErrorMessage="*"></asp:RequiredFieldValidator>
                            </td>
                            <td style="width: 95px;">
                            </td>
                        </tr>
                        <tr>
                            <td style="width: 75px;">
                                新密码：
                            </td>
                            <td style="width: 131px;">
                                <asp:TextBox ID="txtNewpwd" runat="server" TextMode="Password" Width="98px"></asp:TextBox>
                                <asp:RequiredFieldValidator ID="RequiredFieldValidator2" ControlToValidate="txtNewpwd"
                                    runat="server" ForeColor="Red" ErrorMessage="*"></asp:RequiredFieldValidator>
                            </td>
                            <td style="width: 95px;">
                            </td>
                        </tr>
                        <tr>
                            <td style="width: 75px;">
                                确认密码：
                            </td>
                            <td style="width: 131px;">
                                <asp:TextBox ID="txtRepwd" runat="server" TextMode="Password" Width="98px"></asp:TextBox>
                                <asp:RequiredFieldValidator ID="RequiredFieldValidator3" ControlToValidate="txtRepwd"
                                    runat="server" ForeColor="Red" ErrorMessage="*"></asp:RequiredFieldValidator>
                            </td>
                            <td style="width: 95px;">
                                <asp:CompareValidator ID="CompareValidator1" ControlToCompare="txtNewpwd" ControlToValidate="txtRepwd"
                                    runat="server" ErrorMessage="与密码不符！"></asp:CompareValidator>
                            </td>
                        </tr>
                        <tr>
                            <td style="width: 75px;">
                            </td>
                            <td style="width: 131px;">
                                <asp:Button ID="btnUpdate" CommandName="update" runat="server" Text="修改密码" CommandArgument='<%#DataBinder.Eval(Container.DataItem,"Password") %>' />
                                <asp:Button ID="btnCancel" runat="server" CommandName="cancel" Text="取消" CausesValidation="false" />
                            </td>
                            <td style="width: 95px;">
                            </td>
                        </tr>
                    </table>
                </EditItemTemplate>
                <AlternatingItemStyle BackColor="White" ForeColor="#284775" />
                <ItemStyle BackColor="#F7F6F3" ForeColor="#333333" />
                <%--****************Header Template 模板设计代码***********--%>
                <HeaderTemplate>
                    <table style="width: 471px; height: 59px; font-size: 9pt;">
                        <tr>
                            <td style="width: 47px;">
                                用户名
                            </td>
                            <td style="width: 77px;">
                                电子邮件
                            </td>
                            <td style="width: 81px;">
                                是否为管理员
                            </td>
                            <td style="width: 89px;">
                                操作
                            </td>
                            <td style="width: 89px;">
                                管理员设置
                            </td>
                        </tr>
                    </table>
                </HeaderTemplate>
                <HeaderStyle BackColor="#5D7B9D" Font-Bold="true" ForeColor="White" />
                <%--****************SelectedItem Template 模板设计代码***********--%>
                <SelectedItemTemplate>
                    <table style="width: 297px; height: 59px; font-size: 9pt;">
                        <tr>
                            <td style="width: 58px; height: 19px;">
                                用户名:
                            </td>
                            <td style="width: 131px; height: 19px;">
                                <asp:TextBox ID="txtUserName" runat="server" Text='<%#DataBinder.Eval(Container.DataItem,"UserName") %>'></asp:TextBox>
                                <asp:RequiredFieldValidator ID="RequiredFieldValidator4" ControlToValidate="txtUserName"
                                    runat="server" ErrorMessage="*"></asp:RequiredFieldValidator>
                            </td>
                        </tr>
                        <tr>
                            <td style="width: 58px;">
                                Email：
                            </td>
                            <td style="width: 131px;">
                                <asp:TextBox ID="txtEmail" runat="server" Text='<%#DataBinder.Eval(Container.DataItem,"Email") %>'></asp:TextBox>
                                <asp:RequiredFieldValidator ID="RequiredFieldValidator5" ControlToValidate="txtEmail"
                                    runat="server" ErrorMessage="*"></asp:RequiredFieldValidator>
                            </td>
                        </tr>
                        <tr>
                            <td style="width: 58px;">
                            </td>
                            <td style="width: 131px;">
                                <asp:Button ID="btnUpdateName" CommandName="updateName" runat="server" CommandArgument='<%#DataBinder.Eval(Container.DataItem,"UserId") %>'
                                    Text="修改用户信息" Width="90px" />
                                <asp:Button ID="btnCancel" CommandName="cancel" runat="server" Text="取消" CausesValidation="false" />
                            </td>
                        </tr>
                    </table>
                </SelectedItemTemplate>
            </asp:DataList>
        </div>
        <div align="center">
            <asp:HyperLink ID="HyperLink1" runat="server" NavigateUrl="~/User/Login_div.aspx" Text="返回登录页面">返回登录页面</asp:HyperLink>
        </div>
    </div>
    </form>
</body>
</html>
